//
//  YBCloudComputerOpenCell.swift
//  Moonlight
//
//  Created by Penlon Kim on 2023/6/8.
//  Copyright © 2023 Moonlight Game Streaming Project. All rights reserved.
//

import UIKit
import SnapKit

class YBCloudComputerOpenCell: UITableViewCell {
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.selectionStyle = .none
        self.backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        contentView.addSubview(imgView)
        imgView.addSubview(openImgView)
        
        imgView.snp.makeConstraints { make in
            make.top.equalTo(10)
            make.bottom.equalTo(-5)
            make.left.right.equalToSuperview()
            make.height.equalTo((kScreenWidth-20) * 0.326).priority(.high)
        }
        
        openImgView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.size.equalTo(28)
        }
        
    }
    
    /// 重写frame
    override var frame: CGRect {
        get { return super.frame }
        set {
            var frame = newValue
            frame.origin.x += 10
            frame.size.width -= 2*10
            super.frame = frame
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - lazy
    private lazy var imgView: UIImageView = {
        let iv = UIImageView(image: UIImage(named: "icon_cloudcomputer_banner"))
        iv.bk_addCornerBorder(radius: 10, borderWidth: 0.1, borderColor: .clear)
        iv.contentMode = .scaleAspectFill
        iv.clipsToBounds = true
        return iv
    }()
    
    private lazy var openImgView: UIImageView = {
        let iv = UIImageView(image: UIImage(named: "icon_cloudcomputer_open"))
        return iv
    }()
    
}
